import { Entity, PrimaryGeneratedColumn, Column, ManyToMany, JoinTable } from 'typeorm';
import { FieldType } from './field-type.entity';

@Entity()
export class FormConfig {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  name: string; // 配置名称

  @ManyToMany(() => FieldType)
  @JoinTable({
    name: 'form_config_field_types',
    joinColumn: { name: 'form_config_id', referencedColumnName: 'id' },
    inverseJoinColumn: { name: 'field_type_id', referencedColumnName: 'id' }
  })
  fieldTypes: FieldType[];

  @Column({ type: 'json', nullable: true })
  fieldLabels: Record<string, string>; // 自定义字段标签，键为字段key，值为自定义标签
}